﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using TelerikedIn.Models;
using TelerikedIn.WebApp.ViewModels.Skills;

namespace TelerikedIn.WebApp.ViewModels.User
{
    public class FullUserVM
    {
        public string Id { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string City { get; set; }

        public string Country { get; set; }

        public string Education { get; set; }

        public ICollection<SkillToEndorseVM> Skills { get; set; }

        public string Image { get; set; }

        public string FullName { get; set; }

        public static Expression<Func<ApplicationUser, FullUserVM>> FromUser
        {
            get
            {
                return user => new FullUserVM
                {
                    Id = user.Id,
                    FirstName = user.FirstName,
                    LastName = user.LastName,
                    City = user.City,
                    Country = user.Country,
                    Education = user.Education,
                    Image = user.Image != null ? Convert.ToBase64String(user.Image) : null,
                    Skills = user.Skills.AsQueryable().Select(SkillToEndorseVM.FromSkillEntity).ToList(),
                    FullName = user.FirstName + " " + user.LastName
                };
            }
        }

        public bool UsersAreConnected { get; set; }
    }
}